home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 038a / lyapunba.zip / LYAPX12I.BAS < prev    next >
BASIC Source File  |  1991-09-23  |  2KB  |  77 lines

  1.  
  2. DEFINT I-N: DIM rxy(0 TO 1): CLS ' set screen defaults
  3.  
  4. SCREEN 12: CLS : INPUT ; "? default=1"; z: CLS : INPUT ; "-x1 ? default=2"; xz: CLS : INPUT ; "x2 ?-default=4"; xzz: CLS
  5.  INPUT ; "-y1 ?default=2"; yz: CLS : INPUT ; "y2 ?default=4"; yzz: CLS
  6. ' set parameter ranges:
  7. ' niter = the number of iterations
  8. ' x1, x2 = limits of "b" range
  9. ' y1, y2 = limits of "a" range
  10. ' nx, ny = number of pixels
  11. ' xmax = maximum allowed size of iterate, to avoid overflows
  12.  
  13. x1 = -xz: x2 = xzz: y1 = -yz: y2 = yzz
  14. nx = 640: ny = 480: NITER = 256: xmax = 1D+16
  15. '  start iteration with x = x0 = critical point
  16. x0 = .5
  17.  
  18. ' determine pixel steps
  19. dx = (x2 - x1) / nx: dy = (y2 - y1) / ny
  20.  
  21. '  start iterating
  22.  
  23. FOR j = 0 TO ny
  24. ' rxy(0) represents "b" in the "ab" periodic forcing
  25.   rxy(0) = dy * j + y1
  26.   FOR i = 0 TO nx
  27. '   rxy(1) represents "a" in the "ab" forcing
  28.     rxy(1) = dx * i + x1
  29.     x = x0
  30.  
  31. '  iterate niter times to remove transients
  32.     FOR ITER = z TO NITER: '  if l = 1, use "a"; if l = 0, use "b"
  33.     l = ITER MOD 2
  34.     x = x * rxy(l) * (1 - x)
  35.  
  36. '  color divergent points with color #1
  37.     
  38.     IF ABS(x) > xmax THEN k = 1: x = x0: GOTO colorpix
  39.     NEXT ITER
  40.  
  41. '  iterate niter times to compute exponent, stored in al
  42.     al = 0
  43.     FOR ITER = z TO NITER
  44.       l = ITER MOD 2: x = x * rxy(l) * (1 - x)
  45.       IF ABS(x) > xmax THEN k = 1: x = x0: GOTO colorpix
  46. '  d = ABS(the derivative of the function, with respect to x)
  47.       d = ABS(rxy(l) * (1 - 2 * x))
  48. '  avoid trying to find LOG(0)
  49.       IF d = 0 THEN d = 1E-10
  50. '  add LOG(d) to the running total for al;
  51. '  since I will scale al to determine a color mapping scheme, I
  52. '  don't need to divide d by LOG(2), as in the SA article
  53.       al = al + LOG(d)
  54. '  only color points with negative exponents (periodic orbits)
  55. '  change this IF-THEN-ELSE block to show positive exponents (chaotic)
  56.     IF al > 0# THEN
  57.       k = 0
  58.     ELSE
  59. '  at this point, use any scale factors you wish to get a nice
  60. '  distribution of colors
  61.       al = al / (NITER)
  62.      
  63.      
  64.      
  65.       
  66.       k = ((-al * 1000#) MOD 255) + 1
  67.     END IF
  68. colorpix: PSET (i, j), k
  69.  
  70.      NEXT
  71.   NEXT
  72.    NEXT
  73. '  loop until a key is pressed
  74. WHILE INKEY$ = "": WEND
  75. ENDd:  GOTO ENDd
  76.  
  77.